package cn.yastu.adapter.adapter;

import cn.yastu.adapter.adaptee.Pay;
import cn.yastu.adapter.adaptee.SMSPay;
import cn.yastu.adapter.adaptee.STMPay;
import cn.yastu.adapter.adaptee.UnionPay;

/**
 * @author Baldwin
 */
public class PayAdapter implements Pay {

    private Pay pay;

    public PayAdapter(String type) throws ClassNotFoundException {
        switch (type) {
            case "SMS" :
                pay = new SMSPay();
                break;
            case "Union" :
                pay = new UnionPay();
                break;
            case "STM" :
                pay = new STMPay();
                break;
            default:
                throw new ClassNotFoundException("No Pay type is define: " + type);
        }
    }

    @Override
    public void pay(int amount) {
        pay.pay(amount);
    }
}
